/*
 * This source code is part of TWaver 4.0
 *
 * Serva Software PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
 * Copyright 2002 - 2011 Serva Software. All rights reserved.
 */

package demo.chart.survey;

import java.awt.Color;

import twaver.Element;
import twaver.Node;
import twaver.TUIManager;
import twaver.TWaverConst;
import twaver.chart.BarChart;

public class FrameworkChart extends BarChart{
	
	public FrameworkChart(){		
		this.setTitle("Year-over-Year Ajax Use");
		this.setYAxisText("% of Total");
		this.setBackground(SurveyDemo.background);
		this.setBarType(TWaverConst.BAR_TYPE_STACK);
		this.setLegendLayout(TWaverConst.LEGEND_LAYOUT_VERTICAL);
		this.setEnableXZoom(false);
		this.setEnableXTranslate(false);
		this.addXScaleText("2005");
		this.addXScaleText("2006");
		this.addXScaleText("2007");
		this.setXScaleTextColor(Color.BLACK);
		this.setXScaleTextFont(TUIManager.getDefaultBoldFont());
		this.setBackgroundVisible(true);
		this.setBackgroundFillColor(Color.DARK_GRAY);
		this.setXAxisFillColor(Color.LIGHT_GRAY);
		this.setYAxisFillColor(Color.LIGHT_GRAY);
		
		addElement("Prototype", 23.10, 43.10, 34.10, Color.BLUE.brighter().brighter());
		addElement("jQuery", 0.00, 7.20, 29.30, Color.PINK);
		addElement("Ext JS", 0.00, 0.00, 22.50, Color.RED.brighter());
		addElement("Script.aculo.us", 17.70, 32.90,	22.30, Color.ORANGE.brighter());
		addElement("Mootools", 0.00, 11.00,	14.30, Color.GREEN.brighter().brighter());
		addElement("YUI", 0.00,	0.00, 13.00, Color.RED.brighter().brighter());
		addElement("Raw Ajax", 40.00, 25.20, 13.00, SurveyDemo.color);
		addElement("JSON", 0.00, 11.00, 12.90, Color.WHITE);
		addElement("Dojo", 10.20, 18.70, 11.90, Color.ORANGE.darker());
		addElement("Backbase", 2.80, 1.40, 8.30, Color.CYAN);
		addElement("Django", 0.00, 1.60, 8.20, Color.GREEN);
		addElement("DWR", 11.00, 11.60, 4.30, Color.RED);
		addElement("RoR", 10.00, 7.90, 3.90, Color.CYAN.darker());
		addElement("Rico", 6.80, 4.70, 0.80, Color.ORANGE);
		addElement("Ajax.NET", 8.30, 2.20, 1.60, Color.MAGENTA);
		addElement("SAJAX", 6.40, 2.70, 0.50, Color.BLUE);
		addElement("xajax", 3.50, 4.00, 0.20, Color.YELLOW);

	}
	
	private void addElement(String text, double v1, double v2, double v3, Color color){
		Element element = new Node();
		element.setName(text);
		element.putChartColor(color);
		element.addChartValue(v1);
		element.addChartValue(v2);
		element.addChartValue(v3);
		box.addElement(element);
	}
}